package org.gntc.prayer.db;

import android.provider.BaseColumns;

public final class PrayerDBInfo
{
	public static final String CATEGORY_TABLE_NAME = "prayer_category_tbl";
	public static final String PRAYER_TABLE_NAME = "prayer_tbl";
	public static final String ANSWER_TABLE_NAME = "answer_tbl";
	
	/**
	 * TABLE : Category
	 */
	public static final class CategoryTBL implements BaseColumns
	{
		// Columns
		public static final String COL_NAME 		= "catename";				// 카테고리 이름
		public static final String COL_REG_DATE 	= "regdate";				// 생성일
		
		// Create table query
		public static final String CREATE_CATEGORY_TBL = "CREATE TABLE IF NOT EXISTS " + CATEGORY_TABLE_NAME + " " +
														 "( " +
														 	_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
														 	COL_NAME + " TEXT NOT NULL UNIQUE, " +
														 	COL_REG_DATE + " DATE DEFAULT CURRENT_DATE " +
														 ");";

		// Drop table query
		public static final String DROP_CATEGORY_TBL = "DROP TABLE IF EXISTS " + CATEGORY_TABLE_NAME;
	}
	
	/**
	 * TABLE : Prayer
	 */
	public static final class PrayerTBL implements BaseColumns
	{
		// Columns
		public static final String CATEGORY_ID 		= "categoryid";		// 카테고리 ID
		public static final String PRAYER 				= "prayer";			// 기도 제목
		public static final String REGISTERED_DATE 	= "regdate";			// 등록일
		public static final String SET_ALARM 			= "setalarm";			// 알람 설정 여부
		public static final String ALARM_TIME 			= "alarmtime";		// 알람 설정 시간
		
		// Create table query
		public static final String CREATE_PRAYER_TBL = "CREATE TABLE IF NOT EXISTS " + PRAYER_TABLE_NAME + " " +
													   "( " +
													     _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
													     CATEGORY_ID + " INTEGER NOT NULL, " +
													     PRAYER + " TEXT NOT NULL, " +
													     REGISTERED_DATE + " DATE DEFAULT CURRENT_DATE, " +
													     SET_ALARM + " BOOLEAN DEFAULT FALSE, " +
													     ALARM_TIME + " TEXT, " +
													     "FOREIGN KEY (" + CATEGORY_ID + ") REFERENCES " + CATEGORY_TABLE_NAME + " (_id)" +
													     ");";

		// Drop table query
		public static final String DROP_PRAYER_TBL = "DROP TABLE IF EXISTS " + PRAYER_TABLE_NAME;
	}
	
	/**
	 * TABLE : Answer
	 */
	public static final class AnswerTBL implements BaseColumns
	{
		// Columns
		public static final String PRAYER_ID 			= "prayerid";			// Prayer id
		public static final String ANSWER 				= "answer";			// Answer
		public static final String REGISTERED_DATE 	= "regdate";			// 등록일
		
		// Create table query
		public static final String CREATE_ANSWER_TBL = "CREATE TABLE IF NOT EXISTS " + ANSWER_TABLE_NAME + " " +
													   "( " +
													     _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
													     PRAYER_ID + " INTEGER NOT NULL, " +
													     ANSWER + " TEXT NOT NULL, " +
													     REGISTERED_DATE + " DATE DEFAULT CURRENT_DATE, " +
													     "FOREIGN KEY (" + PRAYER_ID + ") REFERENCES " + PRAYER_TABLE_NAME + " (_id)" +
													     ");";

		// Drop table query
		public static final String DROP_ANSWER_TBL = "DROP TABLE IF EXISTS " + ANSWER_TABLE_NAME;
	}
}
